home *** CD-ROM | disk | FTP | other *** search
/ Celestin Apprentice 5 / Apprentice-Release5.iso / Source Code / Libraries / DCLAP 6d / dclap6d / corelib / ncbimath.h < prev    next >
Text File  |  1996-07-05  |  5KB  |  158 lines

  1. /*   ncbimath.h
  2. * ===========================================================================
  3. *
  4. *                            PUBLIC DOMAIN NOTICE
  5. *               National Center for Biotechnology Information
  6. *
  7. *  This software/database is a "United States Government Work" under the
  8. *  terms of the United States Copyright Act.  It was written as part of
  9. *  the author's official duties as a United States Government employee and
  10. *  thus cannot be copyrighted.  This software/database is freely available
  11. *  to the public for use. The National Library of Medicine and the U.S.
  12. *  Government have not placed any restriction on its use or reproduction.
  13. *
  14. *  Although all reasonable efforts have been taken to ensure the accuracy
  15. *  and reliability of the software and data, the NLM and the U.S.
  16. *  Government do not and cannot warrant the performance or results that
  17. *  may be obtained by using this software or data. The NLM and the U.S.
  18. *  Government disclaim all warranties, express or implied, including
  19. *  warranties of performance, merchantability or fitness for any particular
  20. *  purpose.
  21. *
  22. *  Please cite the author in any work or product based on this material.
  23. *
  24. * ===========================================================================
  25. *
  26. * File Name:  ncbimath.h
  27. *
  28. * Author:  Gish, Kans, Ostell, Schuler
  29. *
  30. * Version Creation Date:   10/23/91
  31. *
  32. * $Revision: 2.3 $
  33. *
  34. * File Description:
  35. *       prototypes for portable math library
  36. *
  37. * Modifications:
  38. * --------------------------------------------------------------------------
  39. * Date     Name        Description of modification
  40. * -------  ----------  -----------------------------------------------------
  41. *
  42. * ==========================================================================
  43. */
  44.  
  45. #ifndef _NCBIMATH_
  46. #define _NCBIMATH_
  47.  
  48. #ifdef __cplusplus
  49. extern "C" {
  50. #endif
  51.  
  52. /* log(x+1) for all x > -1 */
  53. double LIBCALL Nlm_Log1p PROTO((double));
  54.  
  55. /* exp(x)-1 for all x */
  56. double LIBCALL Nlm_Expm1 PROTO((double));
  57.  
  58. /* Factorial */
  59. double LIBCALL Nlm_Factorial PROTO((int));
  60.  
  61. /* gamma(x) */
  62. double LIBCALL Nlm_Gamma PROTO((double));
  63.  
  64. /* log(gamma(x)) */
  65. double LIBCALL Nlm_LnGamma PROTO((double));
  66.  
  67. /* log(gamma(n)), integral n */
  68. double LIBCALL Nlm_LnGammaInt PROTO((int));
  69.  
  70. /* digamma(x) 1st order derivative of log(gamma(x)) */
  71. double LIBCALL Nlm_DiGamma PROTO((double));
  72.  
  73. /* trigamma(x) 2nd order derivative of log(gamma(x)) */
  74. double LIBCALL Nlm_TriGamma PROTO((double));
  75.  
  76. /* Nth order derivative of log(gamma) */
  77. double LIBCALL Nlm_PolyGamma PROTO((double x, int order));
  78.  
  79. /* Change gamma coefficients */
  80. void LIBCALL Nlm_GammaCoeffSet PROTO((double PNTR coef, unsigned dimension));
  81.  
  82. /* Nth order derivative of ln(u) */
  83. double LIBCALL Nlm_LogDerivative PROTO((int order, double PNTR u));
  84.  
  85.  
  86. /* Combined Newton-Raphson and Bisection root solver */
  87. double LIBCALL Nlm_NRBis PROTO((double y, double (LIBCALL *f) (double), double (LIBCALL *df) (double), double p, double x, double q, double tol));
  88.  
  89. /* Romberg numerical integrator */
  90. double LIBCALL Nlm_RombergIntegrate PROTO((double (LIBCALL *f) (double, Nlm_VoidPtr), Nlm_VoidPtr fargs, double p, double q, double eps, int epsit, int itmin));
  91.  
  92. /* Greatest common divisor */
  93. long LIBCALL Nlm_Gcd PROTO((long, long));
  94.  
  95. /* Nearest integer */
  96. long LIBCALL Nlm_Nint PROTO((double));
  97.  
  98. /* Integral power of x */
  99. double LIBCALL Nlm_Powi PROTO((double x, int n));
  100.  
  101. /* Random no. seeder and generator */
  102. void LIBCALL Nlm_RandomSeed PROTO((long n));
  103. long LIBCALL Nlm_RandomNum PROTO((void));
  104.  
  105.  
  106. #define Log1p    Nlm_Log1p
  107. #define Expm1    Nlm_Expm1
  108. #define Factorial    Nlm_Factorial
  109. #define Gamma    Nlm_Gamma
  110. #define LnGamma    Nlm_LnGamma
  111. #define DiGamma    Nlm_DiGamma
  112. #define TriGamma    Nlm_TriGamma
  113. #define PolyGamma    Nlm_PolyGamma
  114. #define GammaCoeffSet    Nlm_GammaCoeffSet
  115. #define LogDerivative    Nlm_LogDerivative
  116. #define NRBis    Nlm_NRBis
  117. #define RombergIntegrate    Nlm_RombergIntegrate
  118. #define Gcd    Nlm_Gcd
  119. #define Nint    Nlm_Nint
  120. #define Powi    Nlm_Powi
  121. #define RandomSeed    Nlm_RandomSeed
  122. #define RandomNum    Nlm_RandomNum
  123.  
  124. /* Error codes for the CTX_NCBIMATH context */
  125. #define ERR_NCBIMATH_INVAL    1 /* invalid parameter */
  126. #define ERR_NCBIMATH_DOMAIN    2 /* domain error */
  127. #define ERR_NCBIMATH_RANGE    3 /* range error */
  128. #define ERR_NCBIMATH_ITER    4 /* iteration limit exceeded */
  129.  
  130. #define LOGDERIV_ORDER_MAX    4
  131. #define POLYGAMMA_ORDER_MAX    LOGDERIV_ORDER_MAX
  132.  
  133. #define NCBIMATH_PI    3.1415926535897932384626433832795
  134. #define NCBIMATH_E    2.7182818284590452353602874713527
  135. /* Euler's constant */
  136. #define NCBIMATH_EULER 0.5772156649015328606065120900824
  137. /* Catalan's constant */
  138. #define NCBIMATH_CATALAN    0.9159655941772190150546035149324
  139.  
  140. /* sqrt(2) */
  141. #define NCBIMATH_SQRT2    1.4142135623730950488016887242097
  142. /* sqrt(3) */
  143. #define NCBIMATH_SQRT3    1.7320508075688772935274463415059
  144. /* sqrt(PI) */
  145. #define NCBIMATH_SQRTPI 1.7724538509055160272981674833411
  146. /* Natural log(2) */
  147. #define NCBIMATH_LN2    0.69314718055994530941723212145818
  148. /* Natural log(10) */
  149. #define NCBIMATH_LN10    2.3025850929940456840179914546844
  150. /* Natural log(PI) */
  151. #define NCBIMATH_LNPI    1.1447298858494001741434273513531
  152.  
  153. #ifdef __cplusplus
  154. }
  155. #endif
  156.  
  157. #endif /* !_NCBIMATH_ */
  158.